<?php
/**
 * @Author: Ron Chen
 * @Date:   2016-12-10 11:31:44
 * @Last Modified by:   Ron Chen
 * @Last Modified time: 2018-01-24 22:35:09
 */

namespace common\bases;

use Yii;
use yii\web\Controller;

/**
* 
*/
class BaseController extends Controller
{
	/**
	 * 获得请求对象
	 */
	public function getRequest()
	{
		return Yii::$app->getRequest();
	}
	
	/**
	 * 获得返回对象
	 */
	public function getResponse()
	{
		return Yii::$app->getResponse();
	}

	protected function setSession($session_id){
        \Yii::$app->session->setId($session_id);
        \Yii::$app->session->open();
        if($session_values = \Yii::$app->session->readSession($session_id)){
            @session_decode($session_values);
            if(isset($_SESSION['__id']) && $_SESSION['__id']){
                // \Yii::$app->user->regenerateId = false;
                \Yii::$app->user->switchIdentity(\api\models\User::findById($_SESSION['__id']));
            }
        }
    }
}